
/*
 * Copyright (c) 2021. Dylan Cai
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

@file:Suppress("unused")
package com.gitee.wsl.ext.math

//package com.dylanc.longan


import kotlin.math.*

/**
 * The number of degrees equivalent to π radians.
 */
const val PI_RAD: Float = 180f

/**
 * 180 degrees (π radians) times this value.
 */
inline val Float.piRad: Float
    get() = this * PI_RAD

object Dimensions{

        fun getProgress(current: Float, min: Float, max: Float): Float {
            return abs(current - min) / abs(max - min)
        }

        fun mapRange(value: Float, min: Float, max: Float): Float {
            return min + value * (max - min)
        }

        /**
         * Ensures that a value is within given bounds. Specifically:
         * If value is less than lowerBound, return lowerBound; else if value is greater than upperBound,
         * return upperBound; else return value unchanged.
         */
        fun boundToRange(value: Float, lowerBound: Float, upperBound: Float): Float {
            return lowerBound.coerceAtLeast(value.coerceAtMost(upperBound))
        }

}
